﻿import QtQuick 2.0
import QtQuick.Controls 2.0
import QtGraphicalEffects 1.0

Rectangle {
    property string checkBoxText: ""
    property alias isChecked: checkBox.checked
    signal boxClickedSignal()

    width: 264
    height: 108
    radius: 20
    border.color: "#3F4856"
    color: "#272C39"

    CheckBox {
        id: checkBox
        width: 46
        height: 46
        anchors.verticalCenter: parent.verticalCenter
        anchors.left: parent.left
        anchors.leftMargin: 66
        checked: false
        indicator: Rectangle{
            anchors.fill: parent
            color:   Qt.rgba(255, 255, 255, 0)
            radius: 10
            border.width: 1
            border.color: Qt.rgba(255, 255, 255, 0.5)
            Image{
                id: checkBoxImage
                visible: false
                width: 46
                height: 46
                fillMode: Image.PreserveAspectFit
                source: checkBoxText == "正常" ? "qrc:/imgs/checkbox-ok.png" : "qrc:/imgs/check.png"
            }
        }
        onClicked: {
            if(checked){
                boxClickedSignal()
            }
        }
        onCheckedChanged: {
            checkBoxImage.visible = checked
        }
    }

    Text {
        anchors.verticalCenter: parent.verticalCenter
        anchors.left: checkBox.right
        anchors.leftMargin: 30
        text: checkBoxText
        font.family: "Microsoft YaHei"
        font.pixelSize: 24
        font.bold: true
        color: checkBoxText == "正常" ? "white" : Qt.rgba(255, 255, 255, 0.5)
    }
}
